#include<stdio.h>
#include<stdlib.h>
int compare(const void *a,const void *b)
{
	int *pa=(int *)a;
	int *pb =(int*)b;
	int num1=*pa;
	int num2=*pb;
	return num2-num1;
}

void ResetArray(int input[], int n, int output[])
{	int k=1,a=1;
	qsort(input,n,sizeof(int),compare);
	
	output[n/2]=input[0];
	while(k<n)
	{

		output[n/2-a] = input[k++];
		a++;
		output[n/2+a-1] = input[k++];
	}
}




int main()
{
	int input[]={2,4,1,9,5};
	int i=0;
	int output[10]={0};
	ResetArray(input, 5, output);
	for(i=0;i<5;i++)
{
printf("%d",output[i]);
}

return 0;
}
	
